///页面切换
///传递数据
///页面返回

import 'package:flutter/material.dart';

import 'package:flutter_study/test/AnimatedList.dart';

class Page1 extends StatelessWidget {
  void test(_,__,String v2){
    print(_+__+v2);
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('页面1'),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            RaisedButton(
              child: Text('进入第二页'),
              onPressed: () {
                test('sdf','gasdf','xxxxx');
                test(1,2,'sdf');
                Navigator.of(context).push(
                    MaterialPageRoute(builder: (context) {
                      return Page2(message: "我是第一个页面哦！");
                    })).then((value) {
                  print(value);
                });
              },
            ),
            RaisedButton(
                child: Text('进入第二页02'),
                onPressed: () {
                  Navigator.push(context,
                      PageRouteBuilder(
                          pageBuilder: (BuildContext context, _, __) {
                            return Center(child: AnimatedListSample(),);
                          },
                          transitionsBuilder: (context,Animation<double> animation,
                              _, Widget child) {
                            return FadeTransition(
                              opacity: animation,
                              child: RotationTransition(
                                turns: Tween<double>(begin: 0.5, end: 1.0)
                                    .animate(animation),
                                child: child,),
                            );
                          },
                        transitionDuration: Duration(milliseconds: 300)
                      ));
                }),
          ],
        ),
      ),
    );
  }
}

class Page2 extends StatelessWidget {
  Page2({Key key,this.message}):super(key:key);
  final String message;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('第二个页面'),
      ),
      body: Container(
        child: Center(
          child: RaisedButton(onPressed: (){
            Navigator.pop(context,"我是第二个页面返回结果");
          }),
        ),
      ),
    );
  }
}

